//
//  ZZUIView.swift
//  MeunDemo
//
//  Created by hfzhangzhang on 2018/3/20.
//  Copyright © 2018年 hfzhangzhang. All rights reserved.
//

import UIKit

class ZZUIView: UIView {
}

//添加点击效果
class UIViewEffect : UIView {
    
    var selectColor:UIColor = .clear;
    private var oldColor:UIColor?
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        self.oldColor = self.backgroundColor
        self.backgroundColor = selectColor
    }
    
    override func touchesCancelled(_ touches: Set<UITouch>?, with event: UIEvent?) {
        UIView.animate(withDuration: 0.15, animations: { () -> Void in
            self.backgroundColor = self.oldColor
        })
    }
    
    override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
        UIView.animate(withDuration: 0.15, animations: { () -> Void in
            self.backgroundColor = self.oldColor
        })
    }
}
